{extend name="base"/}
{block name="css"}
<style>
    .layui-body {
        position: absolute;
        left: 200px;
        right: 0;
        top: 20px;
        bottom: 0;
        z-index: 998;
        width: auto;
        overflow: hidden;
        overflow-y: auto;
        box-sizing: border-box;
    }
</style>
{/block}
{block name="content"}
<div class="layui-container">
    <div class="layui-row">
        <div class="layui-col-lg12">
            <fieldset class="layui-elem-field">
                <legend>关于我们</legend>
                <div class="layui-field-box">
                    <form class="layui-form" id="articleForm" enctype="multipart/form-data">
                        <div class="layui-form-item">
                            <label class="layui-form-label">关于我们</label>
                            <div class="layui-input-block">
                                <textarea class="layui-textarea layui-hide" name="content" lay-verify="content" id="news_content">{$about}</textarea>
                            </div>
                        </div>
                        {:token()}
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="addAbout">立即提交</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </fieldset>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<script>
layui.config({
    base: "/static/admin/js/"
}).use(['form', 'layer', 'jquery', 'layedit', 'upload'], function () {
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : parent.layer,
        upload = layui.upload,
        layedit = layui.layedit,
        $ = layui.jquery;
        
        //创建一个编辑器
        var editIndex = layedit.build('news_content', {
            uploadImage: {
                url: '/admin/Notice/uploadImg/'
                ,type: 'post'
            }
        });
        form.on("submit(addAbout)", function (data) {
            data.field.content = layedit.getContent(editIndex);
           
            var formdom = $('#articleForm')[0]
                ,formdata = new FormData(formdom);
            formdata.append('content', layedit.getContent(editIndex));
            $.ajax({
               url: '/backend/config/addAbout',
               type: 'POST',
               data: formdata,
               processData: false, // jQuery不要去处理发送的数据
                contentType: false, // jQuery不要去设置Content-Type请求头
               success: function(res) {
                  console.log(res);
                  if(res==1){
                    top.layer.msg("修改成功！");
                    setTimeout(parent.location.reload(),2500);
                  }else{
                    top.layer.msg("修改失败！");
                    setTimeout(parent.location.reload(),2500);
                  }
               }

           });

        
            return false;
        })
        
});

</script>

{/block}
